Most FTP client programs support an "account" command, (FTP token ACCT), and can be used to activate several features in the VersaTerm FTP Server.
The commands are issued by "account <keyword>" from most UNIX and VMS, FTP client shells.
Keyword:
• mac - use "MacBinary style" binary transfers.
• bin - use "Straight Binary" binary transfers.
• record - records the current date into a file "Last FTP Backup" in your System Folder. This information can be used to record the last time you performed a backup.
Additionally, backup mode is turned off.
• backup - forces ls and dir (NLST and LIST tokens) to only display files that have modification dates newer than the date recorded in your "Last FTP Backup" file. If no file exists, all files are displayed.
• backupNNN (NNN = 1...999) - same as backup, except the "Last FTP Backup" file is ignored and files with modification dates newer than NNN days will be displayed.
• tree - forces ls and dir (NLST and LIST tokens) to display ALL files nested in the directory structure, not just the files in the current directory. A maximum of 19 levels of directories are searched.
• treeN (N = 1...9) - limits the tree command to N levels of directories.
• tree0 - turn off tree mode.
• dirtree - forces ls and dir (NLST and LIST tokens) to display ALL directories nested in the directory structure, not just the files in the current directory. Only directories are listed. A maximum of 19 levels of directories are searched.
• dirtreeN (N = 1...9) - limits the dirtree command to N levels of directories.
• dirtree0 - turn off dirtree mode.
• full - enables full_filenames where '/' characters are used to denote different directories.
• full0 - turn off full_filenames, '/' characters are used as characters of the filename.
Example FTP incremental backup using the VersaTerm FTP Server and UNIX host:
Following is a very simple UNIX style ftp script, lonnie.sh is a shell script that used lonnie.ftp as input. The command "mkbakdir" takes a list of directories and creates the same directories on the host, if necessary.
----Start of File: lonnie.sh
echo "Performing lonnie backup..."
ftp -nv < lonnie.ftp 2> /dev/null
echo "Backup complete."
----End of FIle: lonnie.sh
----Start of File: lonnie.ftp
open lonnie
user backup password
account backup
binary
prompt
macdef dobak
lcd $1
cd $2
account dirtree
mls * tree.dir
!mkbakdir tree.dir $1
account tree
mget *
$ dobak /dat/lra/sys/src /sys/src
$ dobak /dat/lra/sys/MPW /sys/MPW
$ dobak /dat/lra/sys/doc /sys/doc
account recordbackup
quit
----End of File: lonnie.ftp
----Start of File: mkbakdir.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
/*
* Copyright 1991 Abelbeck Software
* by Lonnie R. Abelbeck
*
*/
/*
* remember that mknod() needs super-user permissions!
*/
main(argc, argv)
int argc;
char *argv[];
{
FILE *text;
int mask;
char path[512];
char root[256];
char buf[256];
char *cp;
struct stat sbuf;
unsigned short owner;
unsigned short getuid();
owner = getuid();
if (argc != 3) {
printf("Usage: mkbakdir infile pathname\n");
exit(1);
}
if ((text = fopen(*(argv + 1), "r")) == NULL) {
printf ("mkbakdir: cannot open %s.\n", *(argv + 1));
exit(1);
}
strcpy(root, *(argv + 2));
while (fgets( buf, 256, text) != NULL) {
cp = buf;
while (*cp && *cp != '\n') {
cp++;
}
if (cp == buf) {
continue;
}
*cp = '\0';
strcpy(path, root);
strcat(path, "/");
strcat(path, buf);
if (stat(path, &sbuf) == -1) {
mask |= 0040775;
if (mknod( path, mask, 0) == -1) {
printf("mkbakdir: failed to create directory, %s\n", path);